package cn.dengta.webapp.im.entity;

import java.util.Date;

import cn.dengta.webapp.base.entity.TimeBasedEntity;
import cn.dengta.webapp.model.UpgradeAward;
import cn.dengta.webapp.model.UpgradeBall;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import me.codeplayer.util.Cmp;

@Getter
@Setter
@TableName("im_intimacy_upgrade_award_log")
public class IntimacyUpgradeAwardLog extends TimeBasedEntity {

	/** ID较小的用户ID */
	protected Long lowUserId;
	/** ID较大的用户ID */
	protected Long highUserId;
	/** 升级球类型 */
	private UpgradeBall ballType;
	/** 奖励类型 */
	private UpgradeAward awardType;
	/** 奖励标记 */
	private Integer mark;
	/** 较大的用户ID是否已使用：1=已使用；0=未使用 */
	private Integer useStatus;
	/** 较大的用户ID是否已使用 1=已使用；0=未使用 */
	private Integer highUseStatus;
	// 到期时间
	private Date expireTime;

	public IntimacyUpgradeAwardLog init(Long lowUserId, Long highUserId, UpgradeBall ballType, UpgradeAward awardType, Integer mark) {
		this.lowUserId = lowUserId;
		this.highUserId = highUserId;
		this.ballType = ballType;
		this.awardType = awardType;
		this.mark = mark;
		return this;
	}

	/**
	 * 未过期
	 */
	public boolean nonExpire() {
		return this.expireTime != null && this.expireTime.after(new Date());
	}

	public boolean hasUse(Long userId) {
		return Cmp.eq(userId, this.lowUserId) ? Cmp.eq(this.useStatus, 1) : Cmp.eq(this.highUseStatus, 1);
	}

	public static final String LOW_USER_ID = "low_user_id";
	public static final String HIGH_USER_ID = "high_user_id";
	public static final String USE_STATUS = "use_status";
	public static final String HIGH_USE_STATUS = "high_use_status";
	public static final String EXPIRE_TIME = "expire_time";

}
